/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef RENDER_SERVICE_CORE_PIPELINE_RP_HGM_XML_PARSER_H
#define RENDER_SERVICE_CORE_PIPELINE_RP_HGM_XML_PARSER_H

#include <string>
#include <unordered_map>
#include <vector>

#include <libxml/parser.h>
#include <libxml/tree.h>

namespace OHOS::Rosen {
class RPHgmXMLParser {
public:
    RPHgmXMLParser() = default;
    ~RPHgmXMLParser();

    int32_t LoadConfiguration(const char* fileDir);
    const std::vector<std::string>& GetAppBufferList() const
    {
        return appBufferList_;
    }
    const std::unordered_map<std::string, std::string>& GetSourceTuningConfig() const
    {
        return sourceTuningConfig_;
    }
    const std::unordered_map<std::string, std::string>& GetSolidLayerConfig() const
    {
        return solidLayerConfig_;
    }

private:
    int32_t Parse();
    int32_t ParseNode(xmlNode& node, std::vector<std::string>& data);
    int32_t ParseNode(xmlNode& node, std::unordered_map<std::string, std::string>& data);
    std::string ExtractPropertyValue(const std::string& propName, xmlNode& node);
    xmlDoc* xmlDocument_ = nullptr;
    std::vector<std::string> appBufferList_;
    std::unordered_map<std::string, std::string> sourceTuningConfig_;
    std::unordered_map<std::string, std::string> solidLayerConfig_;
};
} // namespace OHOS::Rosen

#endif // RENDER_SERVICE_CORE_PIPELINE_RP_HGM_XML_PARSER_H